import {defHttp} from '/@/utils/http/axios';
import {Modal} from 'ant-design-vue';

export const getPublisher = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/publisher/get', params});
}
export const listPublisher = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/publisher/list', params});
}
export const pagePublisher = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/publisher/page', params});
}

export const saveOrUpdatePublisher = (params, isUpdate) => {
  let url = '/infra-service/eventBus/publisher/' + (isUpdate ? 'update' : 'save');
  return defHttp.post({url: url, params});
}

export const deletePublisher = (params, handleSuccess) => {
  return defHttp.delete({url: '/infra-service/eventBus/publisher/delete', data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

export const batchDeletePublisher = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({
        url: '/infra-service/eventBus/publisher/batchDelete', data: params
     }, { joinParamsToUrl: true }).then(() => {
        handleSuccess(); 
     });
    }
  });
}



export const getTopic = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/topic/get', params});
}

export const listTopic = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/topic/list', params});
}

export const pageTopic = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/topic/page', params});
}

export const saveOrUpdateTopic = (params, isUpdate) => {
  let url = '/infra-service/eventBus/topic/' + (isUpdate ? 'update' : 'save');
  return defHttp.post({url: url, params});
}

export const deleteTopic = (params, handleSuccess) => {
  return defHttp.delete({url: '/infra-service/eventBus/topic/delete', data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

export const batchDeleteTopic = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({
        url: '/infra-service/eventBus/topic/batchDelete', data: params
     }, { joinParamsToUrl: true }).then(() => {
        handleSuccess(); 
     });
    }
  });
}


export const getSubscriber = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/subscriber/get', params});
}

export const listSubscriber = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/subscriber/list', params});
}

export const pageSubscriber = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/subscriber/page', params});
}

export const saveOrUpdateSubscriber = (params, isUpdate) => {
  let url = '/infra-service/eventBus/subscriber/' + (isUpdate ? 'update' : 'save');
  return defHttp.post({url: url, params});
}

export const deleteSubscriber = (params, handleSuccess) => {
  return defHttp.delete({url: '/infra-service/eventBus/subscriber/delete', data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

export const getSubscribeManage = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/subscribeManage/get', params});
}

export const pageSubscribeManage = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/subscribeManage/page', params});
}

export const saveOrUpdateSubscribeManage = (params, isUpdate) => {
  let url = '/infra-service/eventBus/subscribeManage/' + (isUpdate ? 'update' : 'save');
  return defHttp.post({url: url, params});
}

export const deleteSubscribeManage = (params, handleSuccess) => {
  return defHttp.delete({url: '/infra-service/eventBus/subscribeManage/delete', data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

export const addSubscribeField = (params) => {
  return defHttp.post({url: '/infra-service/eventBus/subscribeManage/addField', params});
}

export const listSubscribeField = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/subscribeManage/listField', params});
}

export const deleteSubscribeField = (params, handleSuccess) => {
  return defHttp.delete({url: '/infra-service/eventBus/subscribeManage/deleteField', data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

export const updateSubscribeField = (params) => {
  let url = '/infra-service/eventBus/subscribeManage/updateField';
  return defHttp.post({url: url, params});
}



export const getNotifyRecord = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/notifyRecord/get', params});
}

export const pageNotifyRecord = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/notifyRecord/page', params});
}


export const listTopicMsgField = (params) => {
  return defHttp.get({url: '/infra-service/eventBus/topic/listField', params});
}

export const saveOrUpdateTopicMsgField = (params, isUpdate) => {
  let url = '/infra-service/eventBus/topic/' + (isUpdate ? 'updateField' : 'saveField');
  return defHttp.post({url: url, params});
}

export const deleteTopicMsgField = (params, handleSuccess) => {
  return defHttp.delete({url: '/infra-service/eventBus/topic/deleteField', data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}